package com.sh;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import com.sh.listener.SmartServerStartupListener;

@SpringBootApplication
@MapperScan("com.sh.mapper")
public class SmartHomeApplication { 

	private static Class<?> cla = SmartHomeApplication.class;
	private static Logger logger = LogManager.getLogger(cla);
	
	public static void main(String[] args) {
		SpringApplication application = new SpringApplication(cla);
		application.addListeners(new SmartServerStartupListener());//添加tcp服务端启动的listener
		ConfigurableApplicationContext cofigAppCont = application.run(args);
		ConfigurableEnvironment confEnv = cofigAppCont.getEnvironment();
		String httpPort = confEnv.getProperty("server.port");
		logger.info("SmartHomeApplication started on port {}, >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", httpPort);
	}
	
}
